package com.itheima.test3;

import org.w3c.dom.ls.LSOutput;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @Author:gy
 * @Date: 2025/09/03 10:06
 * @Description:
 */
public class Demo {
    public static void main(String[] args) throws InterruptedException {
        //我们刚才使用的默认线程池创建线程个数  可以理解为无上限  我想只能在线程池中限定只能最多创建10条线程
        ExecutorService es = Executors.newFixedThreadPool(10);
       /* ThreadPoolExecutor tpe = (ThreadPoolExecutor) es;
        int poolSize = tpe.getPoolSize();
        System.out.println(poolSize);
        int maximumPoolSize = tpe.getMaximumPoolSize();
        System.out.println(maximumPoolSize);*/
        for (int i = 0; i < 15; i++) {
            es.submit(()-> System.out.println(Thread.currentThread().getName()+"在执行了"));
            Thread.sleep(200);
        }
        // es.submit(()-> System.out.println(Thread.currentThread().getName()+"在执行了"));
        es.shutdown();
    }
}
